package com.github.cloud.social;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;

/**
 * Created by guxiaowei on 2018/3/5.
 * 继承默认的社交登录配置，加入自定义的后处理逻辑
 */
//@Component
public class CloudSocialConfigurer extends SpringSocialConfigurer {

    @Autowired
    private AuthenticationSuccessHandler socialLoginSuccessHandler;

    @Override
    protected <T> T postProcess(T object) {
        SocialAuthenticationFilter filter = (SocialAuthenticationFilter) super.postProcess(object);
        filter.setFilterProcessesUrl("/social"); //social 登录地址
        filter.setAlwaysUsePostLoginUrl(true);
        filter.setAuthenticationSuccessHandler(socialLoginSuccessHandler);
        return (T) filter;
    }
}
